// InputDlg.cpp: implementation of the CInputDlg class.
//
//////////////////////////////////////////////////////////////////////

#include "InputDlg.h"
#include <assert.h>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CInputDlg::CInputDlg()
{
    m_szPrompt = NULL;
    m_szInput[0] = '\0';
}

CInputDlg::~CInputDlg()
{

}

void CInputDlg::SetPromptText(char* szPrompt)
{
    assert (szPrompt);
    m_szPrompt = szPrompt;
}

LRESULT CInputDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    assert (m_szPrompt);
    HWND hPromptStatic = GetDlgItem(IDC_PROMPT);
    ::SetWindowText(hPromptStatic, m_szPrompt);
    
    HWND hInput = GetDlgItem(IDC_INPUTTEXT);
    ::SendMessage(hInput, EM_LIMITTEXT, INPUT_SIZE, 0);
    ::SetFocus(hInput);
    CenterWindow (GetParent());
    ShowWindow(SW_SHOW);
    bHandled = TRUE;
    return TRUE;
}

LRESULT CInputDlg::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    return 0;
}

LRESULT CInputDlg::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
    HWND hInput = GetDlgItem(IDC_INPUTTEXT);
    ::GetWindowText(hInput, m_szInput, INPUT_SIZE);
    EndDialog(IDOK);
    return 0;
}

LRESULT CInputDlg::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
    EndDialog(IDCANCEL);
    return 0;
}
